Dashboard Temp Share Shortlinks Frames API

HTMLify

app.js
Views: 8 | Author: huxn-webdev
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let result = document.querySelector(".result-btn");

result.addEventListener("click", decimal);

function decimal() {
  let decimal = document.getElementById("number").value;
  let tempDecimal;
  let rem = 0;
  let binary = 0;
  let place = 1;

  tempDecimal = decimal;

  while (tempDecimal > 0) {
    rem = tempDecimal % 2;
    binary = binary + rem * place;
    tempDecimal = parseInt(tempDecimal / 2);
    place = place * 10;
  }

  const h1 = document.createElement("h1");
  h1.innerHTML = `${binary}`;

  //   h1.style.border = "2px solid black";
  //   h1.style.padding = "10px";
  //   h1.style.marign = "5px";

  const container = document.querySelector(".results-container");
  container.append(h1);
}